package leung.java.hibernate;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;


@Entity
@Table(name="user")
public class User {
	
	@Id
	@GeneratedValue
	private int id;
	private String userName;
	private int age;
	private Date birthday;
	public boolean gender;
	
	
	private Card card;
	
	public User(){
	}
	
	public User(int id){
		this.id=id;
	}
	
	public void print(){
		System.out.println("==========");
		System.out.println(userName);
		System.out.println(age);
		System.out.println(birthday);
		System.out.println(gender);
		System.out.println("==========");
	}

	
	@Column(name="user_name")
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public boolean isGender() {
		return gender;
	}
	
	
	public boolean getGender(){
		return gender;
	}

	public void setGender(boolean gender) {
		this.gender = gender;
	}

	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@OneToOne(optional=true,cascade=CascadeType.ALL)
	@PrimaryKeyJoinColumn
	public Card getCard() {
		return card;
	}

	public void setCard(Card card) {
		this.card = card;
	}
	
}
